bitkeeper revision 1.1056 (40ee8548FSHN81_Xbjs1fGV_cPdH5Q)
authormjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Fri, 9 Jul 2004 11:45:12 +0000 (11:45 +0000)
committermjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Fri, 9 Jul 2004 11:45:12 +0000 (11:45 +0000)
Get the EINTR-safe _readline and _readlines.

tools/python/xen/xend/XendDomainInfo.py

index 89c1731fbc5bb3af56b2970d1b9434cbb321b0ab..89b23054ced2ffc3f9535f1e662e242c0f652d70 100644 (file)
@@ -19,6 +19,7 @@ from twisted.internet import defer
 
 import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
 import xen.util.ip
+from xen.util.ip import _readline, _readlines
 
 import sxp
 
@@ -31,24 +32,6 @@ xend = server.SrvDaemon.instance()
 SIF_BLK_BE_DOMAIN = (1<<4)
 SIF_NET_BE_DOMAIN = (1<<5)
 
-def readlines(fd):
-    """Version of readlines safe against EINTR.
-    """
-    import errno
-    
-    lines = []
-    while 1:
-        try:
-            line = fd.readline()
-        except IOError, ex:
-            if ex.errno == errno.EINTR:
-                continue
-            else:
-                raise
-        if line == '': break
-        lines.append(line)
-    return lines
-
 class VmError(ValueError):
     """Vm construction error."""
 
@@ -90,7 +73,7 @@ def lookup_raw_partn(partition):
 
     if drive == partition:
         fd = os.popen( '/sbin/sfdisk -s ' + drive + ' 2>/dev/null' )
-        line = readline(fd)
+        line = _readline(fd)
         if line:
             return [ { 'device' : blkdev_name_to_number(drive),
                        'start_sector' : long(0),
@@ -102,7 +85,7 @@ def lookup_raw_partn(partition):
     fd = os.popen( '/sbin/sfdisk -d ' + drive + ' 2>/dev/null' )
 
     #['/dev/sda3 : start= 16948575, size=16836120, Id=83, bootable\012']
-    lines = readlines(fd)
+    lines = _readlines(fd)
     for line in lines:
         m = re.search( '^' + partition + '\s*: start=\s*([0-9]+), ' +
                        'size=\s*([0-9]+), Id=\s*(\S+).*$', line)